var request = require('./request.js')

//获取应用实例
const app = getApp()

Page({
  data: {
    bankResults:''
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.getBank();
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  getBank:function(){
    var that = this;
    var bankResults = [];
    var data={
      access_token: wx.getStorageSync('createUser').access_token
    }
    request.getBank(data,function(d){
      if(d.code == 200){
        for (var i = 0; i < d.data.length; i++) {
          bankResults.push(d.data[i]);
        }
        that.setData({
          majorMain: '1',
          bankResults: bankResults
        })
      }
    })
  },
  bankSelected:function(e){
    var current = e.currentTarget.dataset.current;
    console.log(current)
    wx.setStorage({ key: "currentBank", data: current })
    wx.navigateBack({
      delta: 1
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      setLang: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'] : wx.T.locales['en']

    })
    wx.setNavigationBarTitle({
      title: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].chooseBankCard : wx.T.locales['en'].chooseBankCard
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    setTimeout(function () {
      wx.stopPullDownRefresh();
    }, 1000)

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }
})